import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    // 搜索框输入
    input: '',
    // 搜索模块中的输入
    MInput: '',
    // 歌曲列表中正在播放的歌曲
    currentSong: 0,
    // 歌曲已添加
    haveSong: false,
    addSong: false,
    // 播放歌曲
    clickPlaySong: false,
    // songLists上一次的长度
    lastLength: 0,
    // 是否登录
    isLogin: false,
    profile: {},
    // 标记ModHeader获取getLoginStatus的次数
    glsCount: 0,
    // 将歌曲添加到收藏
    showCollect: false,
    // 分享
    showShare: false,
    shareItem: {},
    sid: 0,
  },
  mutations: {
    changeShareItem(state, item) {
      state.shareItem = item;
    },
    changeShowShare(state, flag) {
      state.showShare = flag;
    },
    changeShowCollect(state, flag) {
      state.showCollect = flag;
    },
    changeSId(state, sid) {
      state.sid = sid + '';
    },
    changeProfile(state, pro) {
      state.profile = pro;
    },
    changeIsLogin(state, flag) {
      state.isLogin = flag;
    },
    changeAddSong(state, flag) {
      state.addSong = flag;
    },
    changeHaveSong(state, flag) {
      state.haveSong = flag;
    },
    changeLastLength(state, index) {
      state.lastLength = index;
    },
    changeClickPlaySong(state, flag) {
      state.clickPlaySong = flag;
    },
    changeCurrentSong(state, index) {
      state.currentSong = index;
      // console.log('changeCurrentSong');
    },
    changeInput(state, input) {
      state.input = input;
      // console.log('changeInput');
    },
    changeMInput(state, input) {
      state.MInput = input;
    },
  },
  actions: {},
  modules: {},
});
